/*
 * @Author: 谢小康 2170673706@qq.com
 * @Date: 2023-12-08 16:32:40
 * @LastEditors: 谢小康 2170673706@qq.com
 * @LastEditTime: 2024-01-19 19:19:41
 * @FilePath: \My-bolg\server\util\utils.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
    /* 转义函数 */
const escape=(str)=>{
        str = str.replace(/&/g, '&amp;')
        str = str.replace(/</g, '&lt;')
        str = str.replace(/>/g, '&gt;')
        str = str.replace(/"/g, '&quto;')
        str = str.replace(/'/g, '&#39;')
        str = str.replace(/`/g, '&#96;')
        str = str.replace(/\//g, '&#x2F;')
        return str
}
function getClientIp(req) {
	return req.headers['x-forwarded-for'] ||
	req.ip ||
	req.connection.remoteAddress ||
	req.socket.remoteAddress ||
	req.connection.socket.remoteAddress ||
	'';
}
module.exports = {
    escape,
    getClientIp
}